package org.msfj.admin.api;

import org.msfj.admin.data.service.DictService;
import org.msfj.admin.feign.DicApi;
import org.msfj.admin.vo.DictVo;
import org.msfj.common.model.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
public class DicApiImpl implements DicApi {

    @Autowired
    private DictService dictService;

    @Override
    public CommonResult<DictVo> getByCode(@RequestParam("code") String code) {
        DictVo dicVo = dictService.getByCode(code);
        return CommonResult.ok(dicVo);
    }

    @Override
    public CommonResult<Map<String, String>> getAllTextByIndexKey(@RequestParam("indexKey") String indexKey) {
        Map<String, String> allTextByIndexKey = dictService.getAllTextByIndexKey(indexKey);
        return CommonResult.ok(allTextByIndexKey);
    }
}